package com.zyh.listener;

import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

@Component
public class MyCallBack implements RabbitTemplate.ConfirmCallback {
    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String cause) {
        System.out.println(correlationData);
        String id = correlationData != null ? correlationData.getId() : "";
        if(ack){
            System.out.println("交换机已经收到消息:"+id);
        }else{
            System.out.println("交换机拒绝消息："+id+"；原因："+cause);
        }
    }
}